package com.wxyong3.jredisvisual.main;

import javafx.application.Application;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class Start extends Application {

	public static void main(String[] args) {
		Application.launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		BorderPane pane = new BorderPane();
		Scene scene = new Scene(pane, 800, 600);
		// TOP 工具栏 start
		ReadOnlyDoubleProperty dobleProperty = primaryStage.widthProperty();
		setTop(pane, dobleProperty);

		// LEFT 导航栏
		setLeft(pane);

		primaryStage.setScene(scene);
		primaryStage.setTitle("Redis Visual Tool");
		primaryStage.getIcons().add(new Image("/logo/redis.png"));
		primaryStage.show();
	}

	private Scene setLeft(BorderPane pane) {
		VBox  vbox = new VBox ();
		vbox.setPadding(new Insets(10));
		vbox.setSpacing(10);
		vbox.setStyle("-fx-background-color: #ffffff;");
		vbox.setFillWidth(true);
		vbox.setMinWidth(200);
		
		vbox.getChildren().add(new Text("Data"));
		
		pane.setLeft(vbox);
		return null;
	}

	/**
	 * TOP 工具栏
	 * 
	 * @param pane
	 * @return
	 */
	private void setTop(BorderPane pane, ReadOnlyDoubleProperty dobleProperty) {
		
		MenuBar menuBar = new MenuBar();
		menuBar.prefWidthProperty().bind(dobleProperty);
		pane.setTop(menuBar);
		// 文件菜单
		Menu fileMenu = new Menu("文件");
		MenuItem newMenuItem = new MenuItem("新建链接");
		MenuItem refreshMenuItem = new MenuItem("刷新 F5");
		MenuItem logoutMenuItem = new MenuItem("退出");
		fileMenu.getItems().addAll(newMenuItem, refreshMenuItem, logoutMenuItem);

		// 帮助
		Menu helpMenu = new Menu("帮助");
		MenuItem feedbackMenuItem = new MenuItem("反馈");
		MenuItem aboutMenuItem = new MenuItem("关于");
		helpMenu.getItems().addAll(feedbackMenuItem, aboutMenuItem);

		menuBar.getMenus().addAll(fileMenu, helpMenu);
	}
}
